<?php
/**
 * 
 * User holds Informationen about User und Socket
 * @author G. Peleskei
 *
 */
class User {
	/**
	 * 
	 * Unique ID for every User
	 * @var String
	 */
	private $id = -1;
	
	/**
	 * 
	 * Socket Resource
	 * @var Socket-Resource
	 */
	private $client = null;
	
	/**
	 * 
	 * Server Socket Resource
	 * @var Socket-Resource
	 */
	private $server = null;
	
	/**
	 * 
	 * Header Information from Handshake
	 * @var Header
	 */
	private $header = null;
	
	/**
	 * 
	 * Prefix for Unique ID
	 * @var String
	 */
	const PREFIX = "ws";
	
	/**
	 * 
	 * Constuctor: Creates a User width given Socket Resource
	 * and generating unique ID
	 * @param Socket-Resource $socket
	 */
	public function __construct(&$socket, &$server) {
		$this->clientt = $socket;
		$this->server = $server;
		$this->setId();
	}
	
	
	/**
	 * 
	 * Sets and generates Unique ID
	 * @return User
	 */
	protected function setId() {
		$this->id = uniqid(self::PREFIX);
		return $this;
	}
	
	/**
	 * 
	 * Gets Id
	 * @return String id
	 */
	public function getId() {
		return $this->id;
	}
	
	/**
	 * 
	 * Gets Socket-Resource of User
	 * @return Socket-Resource
	 */
	public function getClient() {
		return $this->client;
	}
	
	/**
	 * Gets Server Socket-Resource of User
	 * @return Socket-Resource
	 */
	public function getServer() {
		return $this->server;
	}
	
	/**
	 * 
	 * Gets Header
	 * @return Header
	 */
	public function getHeader() {
		return $this->header;
	}
}
?>